/*
 * Copyright 2008 Pavel Byles (pavelbyles@gmail.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.pavco.caribbeanvisit.client.ui;
/*
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.xml.sax.SAXException;

import com.google.gwt.xml.client.Document;
import com.google.gwt.xml.client.Node;
import com.google.gwt.xml.client.NodeList;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

//import java.net.MalformedURLException;
//import java.net.URL;
import com.google.gwt.user.client.ui.CaptionPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.xml.client.XMLParser;
import com.pavco.caribbeanvisit.client.models.Country;*/

public class MarkerSlideShow_old {}

/*public class MarkerSlideShow extends Composite implements ClickHandler {
  private final CaptionPanel d = new CaptionPanel();
  private final DockPanel dockPanel = new DockPanel();
  private final DecoratorPanel centrePanel = new DecoratorPanel();
  private final HTML next = new HTML("<u>N</u>EXT");
  private final HTML prev = new HTML("<u>P</u>REV");
  private final HTML imageTitle = new HTML("");
  private final Image centreImg = new Image();
  private ArrayList<Photo> photoList;
  private int currentPhotoIndex = 0;
  private HashMap<Photo, Image> photoImageMap = 
      new HashMap<Photo, Image>();

  public MarkerSlideShow(Country country) {
    centrePanel.add(new HTML("Loading..."));

    try {
      photoList = loadImages("pavelbyles", country.getName());
    } catch (XPathExpressionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    applyStyles();
    next.addClickHandler(this);
    prev.addClickHandler(this);
    centreImg.addClickHandler(this);
    d.setCaptionText(country.getName());
    d.setContentWidget(dockPanel);
    initWidget(d);
    // TODO: Put data here
    dockPanel.add(this.imageTitle, DockPanel.SOUTH);
    dockPanel.add(next, DockPanel.EAST);
    dockPanel.add(prev, DockPanel.WEST);
    // TODO: find a fix for infoWindow resizing and take this out
    centrePanel.setHeight("300px");
    centrePanel.setWidth("300px");
    dockPanel.add(centrePanel, DockPanel.CENTER);
  }
  
  public void showImages() {
    if (photoList.size() > 0) {
      currentPhotoIndex = 0;
      Photo p = photoList.get(currentPhotoIndex);
      centrePanel.clear();
      centrePanel.add(new Image(p.getUrl()));
      imageTitle.setHTML(p.getTitle());
    }
    if (photoList.size() > 1) {
      photoImageMap.put(photoList.get(1), 
          new Image(photoList.get(1).getUrl()));
    }
    if (photoList.size() == 0) {
      centrePanel.clear();
      centrePanel.add(new HTML("No images to load"));
    }
  }
  
  public void onClick(ClickEvent event) {
    Widget sender = (Widget) event.getSource();
    if (sender == next) {
      if (currentPhotoIndex < photoList.size() - 1) {
        ++currentPhotoIndex;
      } else {
        return;
      }
      Photo p = photoList.get(currentPhotoIndex);
      Set<Photo> photoSet = photoImageMap.keySet();
      centrePanel.clear();
      if (!photoSet.contains(p)) {
        photoImageMap.put(p, new Image(p.getUrl()));
      }
      centrePanel.clear();
      centrePanel.add(photoImageMap.get(p));
      imageTitle.setHTML(p.getTitle());
      
      // Now load next image if there is one
      int nextPhotoIndex = currentPhotoIndex + 1;
      if (nextPhotoIndex < photoList.size()) {
        Photo p2 = photoList.get(nextPhotoIndex);
        if (!photoSet.contains(p2)) {
          photoImageMap.put(p2, new Image(p2.getUrl()));
        }
      }
    } else if (sender == prev) {
      if (currentPhotoIndex > 0) {
        --currentPhotoIndex;
      } else {
        return;
      }
      Photo p = photoList.get(currentPhotoIndex);
      Set<Photo> photoSet = photoImageMap.keySet();
      centrePanel.clear();
      if (!photoSet.contains(p)) {
        photoImageMap.put(p, new Image(p.getUrl()));
      }
      centrePanel.add(photoImageMap.get(p));
      imageTitle.setHTML(p.getTitle());
    } else if (sender == centreImg) {
      // TODO: Figure out what you want to do here !!
    }
  }
  
  private ArrayList<Photo> loadImages(String username, String albumName) throws 
      ParserConfigurationException, SAXException, 
      IOException, XPathExpressionException {
    try {
      URL url = new URL("http://picasaweb.google.com/data/feed/api/user/" 
          + username + "/album/" + albumName + "?kind=photo&imgmax=320");
      BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
      String xmlLine = "";

      while ((xmlLine += reader.readLine()) != null) {
        
      }
      Document messageDom = XMLParser.parse(xmlLine);
      NodeList entryNodes = messageDom.getElementsByTagName("entry");
      
      for (int i = 0; i < entryNodes.getLength(); ++i) {
        NodeList entryNodeChildren = entryNodes.item(i).getChildNodes();
        for (int j = 0; j < entryNodeChildren.getLength(); ++j) {
          // get summary node
        }
        Photo p = new Photo();
        //p.setTitle(entryNode.)
      }
      reader.close();
    } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException ioe) {
      // TODO Auto-generated catch block
    }
    ArrayList<Photo> photoList = new ArrayList<Photo>();
    return photoList;
  }
  
  private void applyStyles() {
    centrePanel.setHeight("100px");
    next.addStyleName("nextPrevButton");
    prev.addStyleName("nextPrevButton");
  }
  
  private class Photo {
    String title;
    String url;
    
    public String getTitle() {
      return null;
    }
    
    public void setTitle(String title) {
      this.title = title;
    }

    public String getUrl() {
      return null;
    }
    
    public void setUrl(String url) {
      this.url = url;
    }
  }
}*/
